//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.example.workrecord.common;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
/**
  *@ClassName: Page
  *@Description Page
  *@Author Mr.Bu
  *@Date 2020/4/26 11:16
  *@Version: 1.0
  */
@Data
@ApiModel(description = "分页参数")
public class Page<T> {
    @ApiModelProperty(value = "数据集合")
    private List<T> list;
    @ApiModelProperty(value = "页码")
    private int pageCurrent = 1;//页码
    @ApiModelProperty(value = "每页显示条数")
    private int pageSize = 30;//每页显示条数
    @ApiModelProperty(value = "数据总数")
    private Long total = 0L;//总数
    @ApiModelProperty(value = "总页数")
    private int pageCount = 0;
    private Float avgScore = 0.0F;


    public Page() {
    }

    @JSONField(
            name = "rows"
    )


    public int getPageCount() {
        if (this.total != null && this.pageSize != 0) {
            if ((long)this.pageSize >= this.total) {
                this.pageCount = 1;
                return this.pageCount;
            } else {
                if (this.pageCount == 0 && this.total > 0L && this.pageSize > 0) {
                    this.pageCount = (int)(this.total / (long)this.pageSize);
                    if (this.total % (long)this.pageSize != 0L) {
                        ++this.pageCount;
                    }
                }

                return this.pageCount;
            }
        } else {
            return 0;
        }
    }


}
